package com.gangquan360.smartadmin.module.customer.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.gangquan360.smartadmin.common.anno.NoValidPrivilege;
import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.constant.SwaggerTagConst;
import com.gangquan360.smartadmin.module.customer.domain.dto.CustomerCategoryDTO;
import com.gangquan360.smartadmin.module.customer.domain.dto.CustomerCategoryQueryDTO;
import com.gangquan360.smartadmin.module.customer.service.CustomerCategoryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * [ 客户分类表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-07 17:16:28
 * @since JDK1.8
 */
@RestController
@Api(tags = {SwaggerTagConst.Group2.CUSTOMER_CATEGORY_MANGER})
public class CustomerCategoryController {

    @Autowired
    private CustomerCategoryService customerCategoryService;

    @ApiOperation(value = "分页查询客户分类表",notes = "@author wiggin")
    @PostMapping("/customer/category/page/query")
    public ResponseDTO<PageResultDTO<CustomerCategoryDTO>> queryByPage(@RequestBody CustomerCategoryQueryDTO queryDTO) {
        return customerCategoryService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "获取客户分类",notes = "@author wiggin")
    @GetMapping("/customer/category/list")
    @NoValidPrivilege
    public ResponseDTO<List<CustomerCategoryDTO>> queryList() {
    	return customerCategoryService.queryList();
    }
    
    
    @ApiOperation(value = "添加客户分类表",notes = "@author wiggin")
    @PostMapping("/customer/category/add")
    public ResponseDTO<String> add(@RequestBody @Valid CustomerCategoryDTO addTO){
        return customerCategoryService.add(addTO);
    }

    @ApiOperation(value="修改客户分类表",notes = "@author wiggin")
    @PostMapping("/customer/category/update")
    public ResponseDTO<String> update(@RequestBody @Valid CustomerCategoryDTO updateDTO){
        return customerCategoryService.update(updateDTO);
    }


    @ApiOperation(value="删除客户分类表",notes = "@author wiggin")
    @GetMapping("/customer/category/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return customerCategoryService.delete(id);
    }


    @ApiOperation(value="详情客户分类表",notes = "@author wiggin")
    @GetMapping("/customer/category/detail/{id}")
    public ResponseDTO<CustomerCategoryDTO> detail(@PathVariable("id") Long id){
        return customerCategoryService.detail(id);
    }
}
